package com.hexu.sharedb.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hexu.sharedb.entity.StuActiveInfor;
import com.hexu.sharedb.mapper.StuActiveInforMapper;
import com.hexu.sharedb.service.StuActiveInforService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.sql.Timestamp;
import java.util.List;

/**
 * @author gufusheng
 * @time 2021/7/2 21:28
 */
@Service
public class StuActiveInforServiceImpl implements StuActiveInforService {

    @Resource
    StuActiveInforMapper stuActiveInforMapper;

    @Override
    public List<StuActiveInfor> getList() {
        return stuActiveInforMapper.selectList(new QueryWrapper<StuActiveInfor>());
    }

    @Override
    public StuActiveInfor getById(Integer sid) {
        return stuActiveInforMapper.selectOne(new QueryWrapper<StuActiveInfor>().eq("sid", sid).between("active_time",Timestamp.valueOf("2021-01-19 12:20:00.0"), Timestamp.valueOf("2021-01-19 12:20:00.0") ));
    }

    @Override
    public boolean save(StuActiveInfor stuActiveInfor) {
        return stuActiveInforMapper.insert(stuActiveInfor) > 0 ? true : false;
    }

    @Override
    public StuActiveInfor getByName(Timestamp time) {
        return stuActiveInforMapper.selectOne(new QueryWrapper<StuActiveInfor>().eq("action_time", time));
    }
}
